package com.blog.backend.resp;

import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Setter
@Getter
public class BlogAlbumResp {

    private String albumId;

    private String albumName;

    private String albumDescription;

    private Date createTime;

    private Integer order;

    private Integer isDelete;

    private String albumPhotos;

    private List<PictureUrlResp> imageList;

    private Integer photosNum;

    private Integer watchNum;

    private String timeStr;

    public String getTimeStr() {
        SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
        return format.format(this.createTime);
    }

    public Integer getPhotosNum(){
        if (StringUtils.isNotBlank(this.albumPhotos)){
            String[] split = this.albumPhotos.split(",");
            return split.length;
        }else {
            return 0;
        }
    }
}
